import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method "POST"
        urlPath("/api/register") {
            queryParameters {
                parameter ('TYPE': "student")
                parameter ('PROGRAM': 1)
            }
        }
        body("""
            {
                "username":"lisi",
                "password":"1234",
                "email":"1234566@lisi.com",
                "mobilePhone":"12345678911",
                "createDate":12341123
            }
        """)
        bodyMatchers {
            jsonPath('$.username', byRegex("\\w+"))
            jsonPath('$.password', byRegex(number()))
            jsonPath('$.email', byRegex(email()))
            jsonPath('$.mobilePhone', byRegex(number()))
            jsonPath('$.createDate', byRegex(number()))
        }
        headers {
            header("Content-Type", "application/json;charset=UTF-8")
        }

    }
    response {
        status 201
        body("""{
                "id":"1"
                }
            """)
        bodyMatchers {
            jsonPath('$.id', byRegex(number()))
        }
        headers {
            header("Content-Type", "application/json;charset=UTF-8")
        }
    }
}